package video

import (
	"github.com/labstack/echo"
	auth "tacitus/library/authorized"
)

func RouteApi(g *echo.Group) {
	g.POST("/cate/list", ShowCategoryListHandler)
	g.POST("/cate/tree", ShowCategoryTreeHandler)
	g.POST("/cate/assoc", CreateAssociationHandler)     // 关联视频或视频包
	g.POST("/cate/crumbs", ShowBreadcrumbsHandler)      // 面包屑导航用的接口，获取所有上级分类的编号和名称
	g.POST("/cate/content", ShowCateContentListHandler) // 分类中的内容，即分类下的视频和视频包
	g.POST("/detail", ShowVideoDetailHandler)
	g.POST("/list/record", ShowVideoListWithRecordHandler, auth.CheckLogin) // 查看带有已观看时长的
	g.POST("/pack/detail", ShowPackageDetailHandler)
	g.POST("/watch/write", WriteWatchRecordHandler, auth.CheckLogin) // 写入记录
}

func RouteAdminApi(g *echo.Group) {
	g.POST("/teacher/list", ShowTeacherListHandler)

	g.POST("/list", ShowVideoListHandler)
	g.POST("/detail", ShowVideoDetailHandler)
	g.POST("/create", CreateVideoHandler)
	g.POST("/delete", DeleteVideoHandler)
	g.POST("/update", NullHandler)

	g.POST("/pack/list", ShowPackageListHandler)
	g.POST("/pack/detail", ShowPackageDetailHandler)
	g.POST("/pack/create", CreatePackageHandler)
	g.POST("/pack/delete", DeletePackageHandler)
	g.POST("/pack/update", NullHandler)
	g.POST("/pack/insert", NullHandler) // 在视频包中插入视频

	g.POST("/cate/list", ShowCategoryListHandler)
	g.POST("/cate/tree", ShowCategoryTreeHandler)
	g.POST("/cate/create", CreateCategoryHandler)
	g.POST("/cate/delete", DeleteCategoryHandler)
	g.POST("/cate/update", NullHandler)

	g.POST("/cate/content", ShowCateContentListHandler) // 分类中的内容，即分类下的视频和视频包
	g.POST("/cate/assoc", CreateAssociationHandler)     // 关联视频或视频包
	g.POST("/cate/crumbs", ShowBreadcrumbsHandler)      // 面包屑导航用的接口，获取所有上级分类的编号和名称
	g.POST("/cate/link", CreateLinkHandler)             // 创建链接
}

func NullHandler(c echo.Context) error {
	return nil
}
